#include "../tools.h"



class Solution {
public:
    double helper(double x, int n){
        if(n == 0) return 1.0;

        double cur = helper(x, n / 2);
        cout << cur << endl;
        return (n & 1) == 0 ? cur * cur : cur * cur * x;
    }

    double myPow(double x, int n) {
        if(x == 1.0) return 1.0;
        if(n == 0) return 1.0;
        if(n == 1) return x;
        return n > 0 ? helper(x, n): 1.0 / helper(x, n);
    }
};



int main(int argc, char const *argv[])
{
    Solution sol;

    double x = 2.0;
    int n = 10;

    cout << sol.myPow(x, n);
    
    
    return 0;
}
